package com.mars.foodserver.controller.app;

import com.mars.foodserver.controller.common.BaseController;
import com.mars.foodserver.response.FoodLikeResponse;
import com.mars.foodserver.response.result.R;
import com.mars.foodserver.service.IFoodCollectService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.AllArgsConstructor;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wq
 * @since 2021-07-21
 */
@RestController
@RequestMapping("/food")
@AllArgsConstructor
public class FoodCollectController extends BaseController {

    final IFoodCollectService foodCollectService;


    /**
     * 收藏
     *
     * @param foodId 美食ID
     * @param type   1 收藏 2 取消收藏
     */
    @GetMapping("/collect")
    public R<Void> collect(Integer foodId, Integer type) {
        foodCollectService.collect(getUserId(), foodId, type);
        return R.success();
    }


    /**
     * 点赞列表
     *
     * @return R
     */
    @GetMapping("/collectList")
    public R<List<FoodLikeResponse>> collectList() {
        return R.success(foodCollectService.collectList(getUserId()));
    }
}
